﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace NeonMika.EightTracks
{
    public class Track
    {

        string release_name;

        public string ReleaseName
        {
            get { return release_name; }
            set { release_name = value; }
        }
        bool faved_by_current_user;

        public bool FavedByCurrentUser
        {
            get { return faved_by_current_user; }
            set { faved_by_current_user = value; }
        }
        int year;

        public int Year
        {
            get { return year; }
            set { year = value; }
        }
        string name;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        int play_duration;

        public int PlayDuration
        {
            get { return play_duration; }
            set { play_duration = value; }
        }
        string performer;

        public string Performer
        {
            get { return performer; }
            set { performer = value; }
        }
        int id;

        public int Id
        {
            get { return id; }
            set { id = value; }
        }
        string url;

        public string Url
        {
            get { return url; }
            set { url = value; }
        }

        public Track(XElement xml)
        {

            /*
             *  <track>
          <release-name>Justified</release-name>
          <faved-by-current-user>false</faved-by-current-user>
          <year nil="true"></year>
          <name>Rock Your Body</name>
          <play-duration>0</play-duration>
          <performer>Justin Timberlake</performer>
          <id>16952</id>
          <url>http://8tracks.s3.amazonaws.com/tf/000/016/952/Rock_Your_Body_mp3_887f6e637935be86c382.mp3</url>
        </track>
             * */

            ReleaseName = xml.TryGetStringElement("release-name");
            FavedByCurrentUser = xml.TryGetBoolElement("faved-by-current-user");
            Year = xml.TryGetIntElement("year");
            Name = xml.TryGetStringElement("name");
            PlayDuration = xml.TryGetIntElement("play-duration");
            Performer = xml.TryGetStringElement("performer");
            Id = xml.TryGetIntElement("id");
            Url = xml.TryGetStringElement("url");
        }
    }
}
